package com.codeduck.bean.entity;

import lombok.extern.slf4j.Slf4j;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 通过注解@PostConstruct&@PreDestroy来标注 Bean的 初始化和销毁方法
 *
 * 向 Spring 注册 BeanLifeCycleIII : {@link com.codeduck.bean.config.BeanLifeCycleConfigIII}
 *
 * @author: <a href="mailto:codeduck@163.com">Codeduck</a>
 * @createDate: 2021-12-23
 */
@Slf4j
public class BeanLifeCycleIII {

    private String name;

    public BeanLifeCycleIII() {
        log.warn("bean的构造方法调用完毕");
    }

    public void setName() {
        this.name = "name";
        log.warn("bean#setName 方法调用完毕");
    }

    public void init() {
        log.warn("@Bean#initMethod 方法调用完毕");
    }

    public void destroy(){
        log.warn("@Bean#destroy 方法调用完毕");
    }

    @PostConstruct
    public void postConstruct() {
        log.warn("@PostConstruct 修饰的方法调用完毕");
    }

    @PreDestroy
    public void  preDestroy() {
        log.warn("@PreDestroy 修饰的方法调用完毕");
    }
}
